package com.crrcdt.vue_project.shiro;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.crrcdt.vue_project.entity.Manager;
import com.crrcdt.vue_project.service.ManagerService;
import org.apache.shiro.authc.*;
import org.apache.shiro.realm.AuthenticatingRealm;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.Resource;

/**
 * @Author: wxySmile
 * @Date 19-11-13 上午9:39
 */
public class MyRealm extends AuthenticatingRealm {

    @Autowired
    ManagerService managerService;


    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
        UsernamePasswordToken usernamePasswordToken= (UsernamePasswordToken) authenticationToken;
        Manager manager = managerService.getOne(new QueryWrapper<Manager>().eq("mg_name",usernamePasswordToken.getUsername()));
        return new SimpleAuthenticationInfo(manager,manager.getMgPwd(),this.getClass().getName()) ;
    }
}
